package main

import (
	"fmt"
	"go-web/src/db-demo/utils"
)

func main() {

	err := AddUser(&User{
		Username: "xuguofeng2021",
		Password: "12345678",
		Email:    "xuguofeng1990@126.com",
	})
	if err != nil {
		fmt.Printf("AddUser失败: %v\n", err)
	}
}

type User struct {
	Id       int
	Username string
	Password string
	Email    string
}

func AddUser(user *User) error {
	sqlStr := "insert into go_user (username, password, email) values (?, ?, ?)"
	_, err := utils.Db.Exec(sqlStr, user.Username, user.Password, user.Email)
	return err
}
